Imports System 
Imports System.Text 
Imports System.Data
Imports System.Data.SqlClient
Imports System.Data.Common
Imports System.Collections
Imports System.Collections.Generic
Imports System.ComponentModel
Imports System.Configuration 
Imports System.Xml 
Imports System.Xml.Serialization
Imports SubSonic 
Imports SubSonic.Utilities
Namespace Data
	''' <summary>
	''' Strongly-typed collection for the AspnetApplications class.
	''' </summary>
	<Serializable> _
	Public Partial Class AspnetApplicationsCollection 
	Inherits ActiveList(Of AspnetApplications, AspnetApplicationsCollection)
	    Public Sub New()
		End Sub
	End Class
	''' <summary>
	''' This is an ActiveRecord class which wraps the aspnet_Applications table.
	''' </summary>
	<Serializable> _
	Public Partial Class AspnetApplications 
	Inherits ActiveRecord(Of AspnetApplications)
		#Region ".ctors and Default Settings"
		
		Public Sub New()
			SetSQLProps()
			InitSetDefaults()
			MarkNew()
		End Sub
		
		Public Sub New(ByVal useDatabaseDefaults As Boolean)
			SetSQLProps()
			If useDatabaseDefaults = True Then
				ForceDefaults()
			End If
			MarkNew()
		End Sub
		Public Sub New(ByVal keyID As Object)
			SetSQLProps()
			InitSetDefaults()
			LoadByKey(keyID)
		End Sub
		Public Sub New(ByVal columnName As String, ByVal columnValue As Object)
			SetSQLProps()
			InitSetDefaults()
			LoadByParam(columnName,columnValue)
		End Sub
		Private Sub InitSetDefaults()
			SetDefaults()
		End Sub
		
		Protected Shared Sub SetSQLProps()
			GetTableSchema()
		End Sub
		#End Region
		
		#Region "Schema and Query Accessor"
		
		Public Shared ReadOnly Property Schema() As TableSchema.Table
			Get
				If BaseSchema Is Nothing Then
					SetSQLProps()
				End If
				Return BaseSchema
			End Get
		End Property
		Private Shared Sub GetTableSchema()
			If (Not IsSchemaInitialized) Then
				'Schema declaration
				Dim schema As TableSchema.Table = New TableSchema.Table("aspnet_Applications", TableType.Table, DataService.GetInstance("ClubStarterKitData"))
				schema.Columns = New TableSchema.TableColumnCollection()
				schema.SchemaName = "dbo"
				'columns
				
                
                Dim colvarApplicationName As TableSchema.TableColumn = New TableSchema.TableColumn(schema)
                colvarApplicationName.ColumnName = "ApplicationName"
                colvarApplicationName.DataType = DbType.String
                colvarApplicationName.MaxLength = 256
                colvarApplicationName.AutoIncrement = false
                colvarApplicationName.IsNullable = false
                colvarApplicationName.IsPrimaryKey = false
                colvarApplicationName.IsForeignKey = false
                colvarApplicationName.IsReadOnly = false
                
                
                schema.Columns.Add(colvarApplicationName)
                
                Dim colvarLoweredApplicationName As TableSchema.TableColumn = New TableSchema.TableColumn(schema)
                colvarLoweredApplicationName.ColumnName = "LoweredApplicationName"
                colvarLoweredApplicationName.DataType = DbType.String
                colvarLoweredApplicationName.MaxLength = 256
                colvarLoweredApplicationName.AutoIncrement = false
                colvarLoweredApplicationName.IsNullable = false
                colvarLoweredApplicationName.IsPrimaryKey = false
                colvarLoweredApplicationName.IsForeignKey = false
                colvarLoweredApplicationName.IsReadOnly = false
                
                
                schema.Columns.Add(colvarLoweredApplicationName)
                
                Dim colvarApplicationId As TableSchema.TableColumn = New TableSchema.TableColumn(schema)
                colvarApplicationId.ColumnName = "ApplicationId"
                colvarApplicationId.DataType = DbType.Guid
                colvarApplicationId.MaxLength = 0
                colvarApplicationId.AutoIncrement = false
                colvarApplicationId.IsNullable = false
                colvarApplicationId.IsPrimaryKey = true
                colvarApplicationId.IsForeignKey = false
                colvarApplicationId.IsReadOnly = false
                
						colvarApplicationId.DefaultSetting = "(newid())"
				
                
                schema.Columns.Add(colvarApplicationId)
                
                Dim colvarDescription As TableSchema.TableColumn = New TableSchema.TableColumn(schema)
                colvarDescription.ColumnName = "Description"
                colvarDescription.DataType = DbType.String
                colvarDescription.MaxLength = 256
                colvarDescription.AutoIncrement = false
                colvarDescription.IsNullable = true
                colvarDescription.IsPrimaryKey = false
                colvarDescription.IsForeignKey = false
                colvarDescription.IsReadOnly = false
                
                
                schema.Columns.Add(colvarDescription)
                
				BaseSchema = schema
				
				'add this schema to the provider
                'so we can query it later
                DataService.Providers("ClubStarterKitData").AddSchema("aspnet_Applications",schema)
			End If
		End Sub
		Public Shared Function CreateQuery() As Query
			Return New Query(Schema)
		End Function
		
		#End Region
		
		#Region "Props"
	
          
        <XmlAttribute("ApplicationName")> _
        Public Property ApplicationName As String 
			Get
				Return GetColumnValue(Of String)("ApplicationName")
			End Get
		    
			Set
				SetColumnValue("ApplicationName", Value)
			End Set
		End Property
		
		
		  
        <XmlAttribute("LoweredApplicationName")> _
        Public Property LoweredApplicationName As String 
			Get
				Return GetColumnValue(Of String)("LoweredApplicationName")
			End Get
		    
			Set
				SetColumnValue("LoweredApplicationName", Value)
			End Set
		End Property
		
		
		  
        <XmlAttribute("ApplicationId")> _
        Public Property ApplicationId As Guid 
			Get
				Return GetColumnValue(Of Guid)("ApplicationId")
			End Get
		    
			Set
				SetColumnValue("ApplicationId", Value)
			End Set
		End Property
		
		
		  
        <XmlAttribute("Description")> _
        Public Property Description As String 
			Get
				Return GetColumnValue(Of String)("Description")
			End Get
		    
			Set
				SetColumnValue("Description", Value)
			End Set
		End Property
		
		
		
		
		#End Region
		
		
			    
	    
	    #Region "PrimaryKey Methods"
	    
			Public Function AspnetMembershipRecords() As Data.AspnetMembershipCollection 
	
				Return New Data.AspnetMembershipCollection().Where(AspnetMembership.Columns.ApplicationId, ApplicationId).Load()
	
			End Function
			
			Public Function AspnetPathsRecords() As Data.AspnetPathsCollection 
	
				Return New Data.AspnetPathsCollection().Where(AspnetPaths.Columns.ApplicationId, ApplicationId).Load()
	
			End Function
			
			Public Function AspnetRolesRecords() As Data.AspnetRolesCollection 
	
				Return New Data.AspnetRolesCollection().Where(AspnetRoles.Columns.ApplicationId, ApplicationId).Load()
	
			End Function
			
			Public Function AspnetUsersRecords() As Data.AspnetUsersCollection 
	
				Return New Data.AspnetUsersCollection().Where(AspnetUsers.Columns.ApplicationId, ApplicationId).Load()
	
			End Function
			
		#End Region
		
		
		
		
		
		
	    
	    'no foreign key tables defined (0)
	    
		
	    
	    'no ManyToMany tables defined (0)
	    
		
		#Region "ObjectDataSource support"
		
		''' <summary>
		''' Inserts a record, can be used with the Object Data Source
		''' </summary>
		Public Shared Sub Insert(ByVal varApplicationName As String,ByVal varLoweredApplicationName As String,ByVal varApplicationId As Guid,ByVal varDescription As String)
			Dim item As AspnetApplications = New AspnetApplications()
			
            item.ApplicationName = varApplicationName
            
            item.LoweredApplicationName = varLoweredApplicationName
            
            item.ApplicationId = varApplicationId
            
            item.Description = varDescription
            
			If Not System.Web.HttpContext.Current Is Nothing Then
				item.Save(System.Web.HttpContext.Current.User.Identity.Name)
			Else
				item.Save(System.Threading.Thread.CurrentPrincipal.Identity.Name)
			End If
		End Sub
		''' <summary>
		''' Updates a record, can be used with the Object Data Source
		''' </summary>
		Public Shared Sub Update(ByVal varApplicationName As String,ByVal varLoweredApplicationName As String,ByVal varApplicationId As Guid,ByVal varDescription As String)
			Dim item As AspnetApplications = New AspnetApplications()
		    
                item.ApplicationName = varApplicationName
				
                item.LoweredApplicationName = varLoweredApplicationName
				
                item.ApplicationId = varApplicationId
				
                item.Description = varDescription
				
			item.IsNew = False
			If Not System.Web.HttpContext.Current Is Nothing Then
				item.Save(System.Web.HttpContext.Current.User.Identity.Name)
			Else
				item.Save(System.Threading.Thread.CurrentPrincipal.Identity.Name)
			End If
		End Sub
		#End Region
		#Region "Columns Struct"
		Public Structure Columns
			Dim x as Integer
			
            Public Shared ApplicationName As String = "ApplicationName"
            
            Public Shared LoweredApplicationName As String = "LoweredApplicationName"
            
            Public Shared ApplicationId As String = "ApplicationId"
            
            Public Shared Description As String = "Description"
            
		End Structure
		#End Region
	End Class
End Namespace
